
function RestoreCameraDefault(a)
{
	flashpoint();



	printf('# for most parameter tags');
	printf('# can run RestoreCameraDefault(param,...)');
	printf('# select from the listings (a-z)');
	printf('# select the parameter tag ');
	printf('# select either User or Factory ');
	printf('# exit the script, and check the camera ');
	printf('# to see if it was successfull');
	
	var alphaNum = new Array();		// associate a number with each alpha character

//	var usetVar=new Array("uset0","uset1","uset2","uset3","uset4","uset5","uset6","uset7" );
//	var isetVar=new Array("iset0","iset1","iset2","iset3","iset4","iset5","iset6","iset7" );
//	var ssetVar=new Array("sset0","sset1","sset2","sset3","sset4","sset5","sset6","sset7" );
	
//	var setTitle=new Array("title0","title1","title2","title3","title4","title5","title6","title7" );

	var i,setting,achar,count;
	
	writeMenu('"RestoreCameraDefault"','"EXTRA"','"RCDOption"');
	writeVariables();
	printf('declare s: readwrite ');

//	print('declare u: uset0');
//	for(i=1 ;i< usetVar.length ; i++) print(",",usetVar[i]); printf(' ');
//	print('declare i: iset0');
//	for(i=1 ;i< isetVar.length ; i++) print(",",isetVar[i]); printf(' ');
//	print('declare s: sset0');
//	for(i=1 ;i< ssetVar.length ; i++) print(",",ssetVar[i]); printf(' ');

//	print('declare s: title0');	
//	for(i=1 ;i< setTitle.length ; i++) print(",",setTitle[i]); printf(' ');

	printf('declare u: doit,countSetting');
	
	printf('<br>','#**** OPEN FILE ****');
  	printf('outFile="/System/ZRCD.txt"');
	writeFileOpen();


	/*
	 * MENU 1 
	 * for each alphabetic character(a,b,c....z) write a SetOption
	 * but only for one that's used
	 * user selects first character of parameter tag (i.e. a for acpd )
	 */
	 
	achar=" ";		// start with a blank
	count=1;
	printf('LOOP:');
	printf('DisplayClear()');
	printf('SetOption( 0,"RESTORE ALL",1) ');
	for( i=1; i<a.length ; i++)
	if( a[i].param.substring(1,2) != achar  ){
			achar=a[i].param.substring(1,2);					// save the first character
			alphaNum[ a[i].param.substring(1,2) ] = count;		// and count associated with this char
			printf('SetOption(',count,',"',achar , '",0)' );	// do the SetOption stuff
			count++;	
	} 
	printf('GetOption(choice)');
	

	/*
	 * MENU 2
	 * place all tags starting with 'a' together in one option list
	 * do the same for 'b', 'c', etc,..
	 * example "deft", "dfmt", "drdn" will all be in the same menu list
	 */	 

	achar=" ";		// start with a blank
	count=0;
		
	printf('<br>if choice == 0');
	printf('choice2=0 ');
	printf('end ');
	printf(' ');
	for( i=1; i<a.length ; i++){
	
//	if( a[i].host == "Read") continue;

	if( a[i].param.substring(1,2) != achar )
	{
			// finished off previous option list
			if( i!=1){
					printf('GetOption(choice2)');	
					printf('end<br>');
			}

 			count++;			
			printf('if choice == ',alphaNum[ a[i].param.substring(1,2) ] );		// get count value
			printf('SetOption(500,"Quit",1)');
											
			achar=a[i].param.substring(1,2);												
	}	
				
		printf('SetOption(',i,",",a[i].param,',0)' );
	}// end of for loop 

	// the last one has to have this, a hack, sorry.......
	printf('GetOption(choice2)');	
	printf('end');


/* MENU 3 (lowest layer)
 * This one has ONE parameter tag per if ... end set
 * there are 2 options available, either user or factory
 */
 
  	printf(' ');
  	printf('MENU3:');
  	printf('<br>if choice2 == 0')
  	printf('param = ""');
  	printf('end');
  	
	for(i=1 ; i<a.length ; i++){ 		 		
 		printf('<br>if choice2 == ',i  );
		printf('param = ',a[i].param );
		printf('end');
	}
		
 	printf('SetOption(0," Factory ") ');
 	printf('SetOption(1," User ") ');
 	printf('GetOption( choice3 ) ');
 	
 	printf('status=RestoreCameraDefault( choice3, param )');
    
    printf('if choice2 == 0' );
    printf('DisplayLine("ALL[",status,"]" ) ' );
    printf('end');

    printf('if choice2 != 0' );
    printf('DisplayLine( param,"[",status,"]" ) ' );
    printf('end');
    
    
	printf('if choice2 != 500');
	printf('goto LOOP');
	printf('end');
	
	writeFileClose();
	printf('exitscript');

}

